using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[Serializable]
public class SelectWeapon: UnityEvent<GameWeapon> {}

/**武器UI */
public class WeaponUI : MonoBehaviour
{
    /**选择武器事件监听 */ 
    public SelectWeapon onSelectWeapon;

    /**武器对象 */
    public GameObject weapon;
    
    /**武器图片集合 */
    public Sprite[] weaponImgs;
    
    /**武器类型 */
    private GameWeapon _type;
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void SetType(GameWeapon type)
    {
        _type = type;
        weapon.GetComponent<Image>().sprite = weaponImgs[(int) type];
    }
    
    public void IsSelect(GameWeapon selectType)
    {
        bool isSelect = selectType == _type;
        GetComponent<RectTransform>().localScale = new Vector3(isSelect ? 1.5f : 1.0f, isSelect ? 1.5f : 1.0f, 1.0f);
    }
}
